<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>09.v-for循环指令</title>
    <script src="./lib/vue-2.6.12.js"></script>
</head>

<body>
    <div id="app">
        <!-- 遍历简单数组 -->
        <span v-for="item in list">{{item}}, </span>
        <hr>
        <span v-for="(item, idx) in list">{{idx}}-{{item}}, </span>
        <hr>
        <!-- 遍历对象数组 -->
        <p v-for="user in users">id={{user.id}}, 姓名={{user.name}}</p>
        <!-- 遍历对象属性 -->
        <hr>
        <p v-for="(val, key) in student">值是：{{val}}，键是：{{key}}</p>
    </div>

    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                list: ['a', 'b', 'c', 'd', 'e', 'f'],
                users: [
                    { id: 10, name: '张三' },
                    { id: 11, name: '李四' },
                    { id: 12, name: '王五' },
                    { id: 13, name: '赵六' }
                ],
                student: {
                    id: 101,
                    name: '查理斯',
                    gender: 'nan'
                }
            }
        })        
    </script>
</body>

</html>